package model.calendar;

import java.io.Serializable;
import java.util.ArrayList;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import model.Link;

@XmlRootElement(name = "maincalendar")
public class MainCalendar extends Link implements Serializable
{
	private static final long serialVersionUID = 3781779856071563112L;

	private static int i = 0;
	
	@XmlAttribute
	private String id = "";
	
	@XmlAttribute
	private String name;
	
	@XmlAttribute
	private String description;
	
	@XmlAttribute
	private String warning;
	
	@XmlAttribute
	private String shared;
	
	@XmlElement(name = "calendar")
	private ArrayList<Calendar> calendars = new ArrayList<Calendar>();
	
	public MainCalendar() {}
	
	public MainCalendar(String name, String description, String warning, String shared)
	{
		i++;
		this.id = i + "";
		this.name = name;
		this.description = description;
		this.warning = warning;
		this.shared = shared;
	}
	
	public Calendar createCalendar(String name)
	{
		Calendar calendar = new Calendar(name);
		calendars.add(calendar);
		return calendar;
	}
	
	public Calendar createCalendar(String id, String name)
	{
		Calendar calendar = new Calendar(id, name);
		calendars.add(calendar);
		return calendar;
	}
	
	public String toString()
	{
		String out = "\n";
		for (int i = 0; i < calendars.size(); i++)
		{
			out += calendars.get(i) + "\n";
		}
		return "MainCalendar id(" + id + ") -> Name: " + name + " | Description: " + description + " | warning: " + warning + " | Shared: " + shared + out;
	}

	public String getId()
	{
		return id;
	}

	public void setId(String id)
	{
		this.id = id;
	}

	public String getName()
	{
		return name;
	}

	public String getDescription()
	{
		return description;
	}

	public String getWarning()
	{
		return warning;
	}

	public String getShared()
	{
		return shared;
	}

	public ArrayList<Calendar> getCalendars()
	{
		return calendars;
	}
}